<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>百度地图图层学习实例</title>
    <!--加一下这个移动端的自适应-->
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <!--在这里添加下百度地图的浏览器端的密钥-->
    <script src="http://api.map.baidu.com/api?v=2.0&ak=TtGaf9hTGI6iO6oB6Y9vqOmnruoIHXLB" type="text/javascript"></script>
    <style>
        html {
            height:100%;
        }
        body {
            height:100%;
            margin:0;
            padding:0;
        }
        #container {
            height:100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
</body>
</html>
<script>
//    var map = new BMap.Map("container");         // 创建地图实例
//     var point = new BMap.Point(113.758652,34.734857);  // 创建点坐标
//     map.centerAndZoom(point, 15);                 // 初始化地图，设置中心点坐标和地图级别
//     var traffic = new BMap.TrafficLayer();        // 创建交通流量图层实例
//     map.addTileLayer(traffic);                    // 将图层添加到地图上
//
//    //搜索服务
//    var local = new BMap.LocalSearch(map, {
//        renderOptions:{map: map}
//    });
//    local.search("郑州世纪欢乐园");


//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
//var local = new BMap.LocalSearch("北京市",
//        {renderOptions: {map: map,autoViewport: true},pageCapacity: 8});
//local.search("中关村");
//结果面板
//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
//var local = new BMap.LocalSearch(map,
//        {renderOptions: {map: map,panel: "results"}});
//local.search("中关村");
//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
//var options = {
//    onSearchComplete: function(results){
//        if (local.getStatus() == BMAP_STATUS_SUCCESS){
//            // 判断状态是否正确
//            var s = [];
//            for (var i = 0; i < results.getCurrentNumPois(); i ++){
//                s.push(results.getPoi(i).title + ", " + results.getPoi(i).address);
//            }
//            document.getElementById("log").innerHTML = s.join("<br>");
//        }
//    }
//};
//var local = new BMap.LocalSearch(map, options);
//local.search("公园");
//周边搜索
//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(113.758652, 34.734857));
//var local = new BMap.LocalSearch(map,
//        { renderOptions:{map: map, autoViewport: true}});
//local.searchNearby("小吃", "二七区");

//矩形范围搜索
//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(113.758652, 34.734857), 14);
//var local = new BMap.LocalSearch(map,
//        { renderOptions:{map: map}});
//local.searchInBounds("银行", map.getBounds());
//公交导航
//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(113.758652, 34.734857), 14);
//var transit = new BMap.TransitRoute(map, {
//    renderOptions: {map: map}
//});
//transit.search("郑州火车站", "河南商报");
//驾车导航
//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(113.758652, 34.734857), 14);
//var driving = new BMap.DrivingRoute(map, {
//    renderOptions: {
//        map: map,
//        autoViewport: true
//    }
//});
//driving.search("河南商报", "郑州海洋馆");
//var map = new BMap.Map("container");
//map.centerAndZoom(new BMap.Point(113.758652, 34.734857), 11);
//// 创建地址解析器实例
//var myGeo = new BMap.Geocoder();
//// 将地址解析结果显示在地图上，并调整地图视野
//myGeo.getPoint("河南商报", function(point){
//    if (point) {
//        map.centerAndZoom(point, 16);
//        map.addOverlay(new BMap.Marker(point));
//    }
//}, "郑州市");
var map = new BMap.Map("container");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
// 创建地理编码实例
var myGeo = new BMap.Geocoder();
// 根据坐标得到地址描述
myGeo.getLocation(new BMap.Point(116.364, 39.993), function(result){
    if (result){
        alert(result.address);
    }
});
</script>